<?php
require 'includes/config.php';
require 'includes/auth.php';
$msg = "default";
if (isset($_POST['submit'])) {
	$request = new makeRequest($backend.'api.php?method=user&auid='.$_SESSION['uid'].
	'&accesstoken='.$_SESSION['accesstoken'],'DELETE');
	$tmp = $request->makeRequest();
	$rbody = $tmp[0];
	$http_code = $tmp[1];
	// Check for errors
	if($http_code == 200){
		$msg = "User deleted!";
	}else{
		$msg = "Something went wrong, please try again later. <br />http error code: ".$http_code;
	}
}

require 'includes/header.php';
require 'includes/topmenu.php';
echo '<div id="kaka">';
require 'includes/sidemenu.php'
?>
<div id="content"><?php
/* Content shown on page */
if($msg != "default"){
	echo $msg;
}
?>
<p>Are you sure that you want to delete your account? <br />
Friendlist, teams and leagues will be lost!</p>
<form method="post" action="<?php echo $PHP_SELF; ?>"><input
	type="submit" Value="Delete" name="submit" /></form>
<br />
<br />
<br />
<a href="profile.php" target="_self">Take me out of here!</a> <?php
require 'includes/footer.php';
?>